This line is commonly attributed to John Keats (e.g. on an episode of Midsomer Murders that I happened to catch a glimpse of the other evening, and on countless websites), but I can find no reliable source that concurs. In the Oxford Dictionary of Quotations (7th edition, 2009) I found it attributed to the German playwright Friedrich Halm (pen name of Baron Eligius Franz Joseph von Münch–Bellinghausen, 1806–71).
It appears in a play entitled Der Sohn der Wildniss (Son of the Wild). The full stanza reads, in German, Mein Herz ich will dich fragen, / Was ist denn Liebe, sag? / "Zwei Seelen und ein Gedanke, / Zwei Herzen und ein Schlag." A literal translation might be "My heart I will ask you / What is love, say? / Two souls and one thought / Two hearts and one beat."
Wikiquote refers to two translations of the play. The playwright apparently preferred the one by W. H. Charlton, which translates the stanza as "My heart I fain would ask thee / What then is Love? say on. / 'Two souls and one thought only / Two hearts that throb as one.'" The more popular English version is by Marie Lovell, which gives it the title of Ingomar, the Barbarian. This has the last two lines as "Two souls with but a single thought, / Two hearts that beat as one."
Ingomar the Barbarian was filmed in 1908, directed by D. W. Griffith. I'm guessing that this is what made the quotation famous; although as the film was obviously a silent one, it was presumably on a graphic.
It's arguably even more famous in a parodied version – in the motto of the Sons of the Desert (the official Laurel & Hardy Appreciation Society): "Two minds without a single thought."
No idea how it came to be attributed to Keats.
And if (like me) you were wondering where the Baron got his pseudonymous surname from: it's a noun, meaning 'stalk'. Beyond that ... no idea either!
© Haydn Thompson 2021